import 'package:flutter/material.dart';
import 'package:flutterapp/chapter/six/scroll_6_3_grid_view.dart';
import 'package:flutterapp/chapter/six/scroll_6_4_custom_scroll_view.dart';
import '../../utils/navigator_utils.dart';
import 'scroll_6_1_single_child_scroll_view.dart';
import 'scroll_6_2_list_view.dart';

// 可滚动组件
class SixRoute extends StatefulWidget {
  @override
  _SixRouteState createState() => _SixRouteState();
}

class _SixRouteState extends State<SixRoute> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("第六章 可滚动组件"),
      ),
      body: _SixRouteBody(),
    );
  }
}

class _SixRouteBody extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(left: 20.0),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: _getWidget(context),
      ),
    );
  }

  List<Widget> _getWidget(BuildContext context) {
    return [
      RaisedButton(
          child: Text("可滚动组件：SingleChildScrollView"),
          onPressed: () =>
              NavigatorUtil.goPageByPush(context, SingleChildScrollViewRote())),
      RaisedButton(
          child: Text("可滚动组件：ListView"),
          onPressed: () =>
              NavigatorUtil.goPageByPush(context, ListViewRoute())),
      RaisedButton(
          child: Text("可滚动组件：GridView"),
          onPressed: () =>
              NavigatorUtil.goPageByPush(context, GridViewRoute())),
      RaisedButton(
          child: Text("可滚动组件：CustomScrollView"),
          onPressed: () =>
              NavigatorUtil.goPageByPush(context, CustomScrollViewRoute())),
    ];
  }
}
